var a = getApp();

Page({
    data: {
        page: 1,
        first_data: [],
        info: [],
        datas: []
    },
    onLoad: function(a) {
        wx.setNavigationBarTitle({
            title: "期刊杂志"
        }), this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (!(this.data.current_page >= this.data.last_page)) {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), this.getMore();
        }
    },
    onShareAppMessage: function() {
        var a = wx.getStorageSync("yz_uid");
        return a && (mid = a), {
            title: "期刊杂志",
            path: "/packageH/article/periodicalIndex/periodicalIndex",
            imageUrl: this.data.first_data.cover
        };
    },
    goDetail: function(a) {
        var t = a.currentTarget.dataset.id;
        console.log(a), wx.navigateTo({
            url: "/packageH/article/periodicalDetail/periodicalDetail?id=" + t
        });
    },
    getData: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.journal.frontend.journal.index");
        a._postNetWork({
            url: e,
            data: {
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                wx.hideLoading({
                    success: function(a) {}
                }), 1 == e.result ? t.setData({
                    datas: e.data.before_journal.data,
                    info: e.data,
                    first_data: e.data.first_data,
                    current_page: e.data.before_journal.current_page,
                    last_page: e.data.before_journal.last_page
                }) : console.log(e);
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    getMore: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.journal.frontend.journal.index");
        a._postNetWork({
            url: e,
            data: {
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                wx.hideLoading({
                    success: function(a) {}
                }), 1 == e.result ? t.setData({
                    datas: t.data.concat(e.data.before_journal.data),
                    current_page: e.data.before_journal.current_page,
                    last_page: e.data.before_journal.last_page
                }) : console.log(e);
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    }
});